<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>管理后台</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link href="/favicon.ico" type="image/x-icon" rel="shortcut icon" />
    <!-- Bootstrap 3.3.4 -->
    <link href="/public/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/admin/css/ratuo.css" rel="stylesheet">

    <script src="/public/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/admin/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="/public/admin/js/common.js"></script>
    <script src="/public/admin/js/plugins/layer/layer.min.js"></script>
    <script src="/public/admin/js/myAjax.js"></script>
    <script src="/public/admin/js/jquery.validate.js"></script>

    <link href="/public/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <script src="/public/admin/js/plugins/iCheck/icheck.min.js"></script>

    <script src="/public/admin/js/article.js"></script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>文章列表</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                    <div class="panel-body">
                                        <form id="formSearch" action="{:url('exam/index')}" method="get" class="form-horizontal form-inline">
                                            <b>科目：</b>
                                            <select class="form-control kind_id" name="subjectid">
                                                <option value="">所有科目</option>
                                                {foreach name="subjectList" item="v"}
                                                <option value="{$v.subjectid}" {eq name="v.subjectid" value="$inputData['subjectid']"}selected="selected"{/eq}>{$v.subject_name}</option>
                                                {/foreach}
                                            </select>
                                            <label class="control-label">关键字：</label>
                                            <input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control" value="{$inputData['keyword']}">
                                            <button type="submit" style="margin-left:30px" id="btn_query" class="btn btn-primary">查询</button>
                                            <button onclick="window.location.href=location.href;"  class="btn btn-primary " style="float: right; margin-top: 10px;margin-right:10px;"><i class="glyphicon glyphicon-refresh"></i>刷新</button>
                                            <a href="javascript:;" onclick="openYemian('/index.php/Admin/Exam/examAdd','添加试卷')" class="btn btn-primary J_menuItem" data-index="10" style="float: right;margin-right:10px; margin-top: 10px;"><i class="fa fa-plus"></i>添加</a>
                                        </form>
                                    </div>
                                </div>
                                <div class="box-body">
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div id="ajaxList">
                                                
                                                <form method="post" enctype="multipart/form-data" id="form-order">
                                                <table class="table table-bordered table-hover">
                                                    <thead>
                                                    <tr>
                                                        <th>ID</th>
                                                        <th>科目</th>
                                                        <th>试卷名称</th>
                                                        <th>添加人</th>
                                                        <th>添加时间</th>
                                                        <th style="display:none">排序</th>
                                                        <th>操作</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody id="ajaxList">
                                                    {if empty($examList)}
                                                    <tr>
                                                        <td colspan="7" align="center">暂无数据</td>
                                                    </tr>
                                                    {/if}
                                                    {foreach name="$examList" item="v" key="k" }
                                                    <tr role="row">
                                                        <td>{$v.examid}</td>
                                                        <td>{$v.subject_name}</td>
                                                        <td><a>{$v.exam_name|getSubstr=0,33}</a></td>
                                                        <td>{$v.add_name}</td>
                                                        <td>{$v.add_time|date="Y-m-d H:i"}</td>
                                                        <td style="display:none"><input type="text" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onchange="updateSort('exam','examid','{$v.examid}','exam_order',this)" size="4"  value="{$v.exam_order}" /></td>
                                                        <td>
                                                            <a onclick="openYemian('/index.php/Admin/Exam/examLook/examid/{$v.examid}','查看试卷')" class="btn btn-primary" href="javascript:;" title="预览试卷"><i class="fa fa-eye"></i></a>
                                                            <a onclick="openYemian('/index.php/Admin/Exam/examEdit/examid/{$v.examid}','编辑试卷')" class="btn btn-primary" href="javascript:;" title="编辑"><i class="fa fa-pencil"></i></a>
                                                            <a class="btn btn-danger" href="javascript:void(0)" title="删除" onclick="delarticle(this,'确定删除该试卷？',{$v.examid},'/index.php/Admin/Exam/examHide')"><i class="fa fa-trash-o"></i></a>
                                                        </td>
                                                    </tr>
                                                    {/foreach}
                                                    </tbody>
                                                </table>
                                            </form>
                                            <div>
                                                <div style="float:left;display:none"><a href="javascript:void(0);" onclick="reback_select()" id="button-delete6" data-toggle="tooltip" title="删除" class="btn btn-danger" data-original-title="放入回收站">把选中文章放入回收站</a></div>
                                                <div style="float:right;margin-top:-20px;" id="pagelist">{$examPage|raw}<span style="float:right;margin:25px">共{$examCount}条</span></div>
                                            </div>
                                            <script>
                                                // 点击分页触发的事件
                                                    $(".pagination a").click(function(){
                                                        url = $(this).attr('href');
                                                        ajax_get_table('formSearch',url);
                                                        return false;
                                                    });
                                                // 删除选中
                                                function reback_select(){
                                                    parent.layer.confirm('确定把选中文章加入回收站？', function(){
                                                        url = window.location.href;
                                                        $.ajax({
                                                            url:"/index.php/Admin/article/reback_select",
                                                            data : $('#form-order').serialize(),
                                                            success: function(v){
                                                                var v =  eval('('+v+')');
                                                                parent.layer.msg(v.message, {icon: v.icon,time: 1000});
                                                                if(v.hasOwnProperty('status') && (v.status == 1))
                                                                    getAjaxList('ajaxList',1,"/index.php/Admin/Article/ajaxArticleList");
                                                            }
                                                        });
                                                    });
                                                }

                                                function attrBg(obj){
                                                    if($(obj).prop('checked')){
                                                        $(obj).closest('tr').addClass('active_bg');
                                                    }else{
                                                        $(obj).closest('tr').removeClass('active_bg');
                                                    }
                                                }
                                            </script>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<input id="handle_status" value="" hidden="hidden">
<input id="kind_id" value="0" hidden="hidden">

<script>
    function delarticle(obj,name,id,url) {
        top.layer.confirm(name,{
            icon : 3,
            btn:['确定','取消'],
        } , function(){
            $.ajax({
                url : url,
                type : "post",
                data : {id:id,act:'del'},
                dataType : "json",
                success:function(data){
                    if (data.status == 0) {
                        top.layer.msg(data.message);
                    } else {
                        top.layer.msg(data.message);
                        $(obj).parent().parent().remove();
                    }
                }
            });
        } , function(){
            layer.close(); //再执行关闭
        })
    }

    function copyarticle(obj,name,id,url) {
        top.layer.confirm(name,{
            icon : 3,
            btn:['确定','取消'],
        } , function(){
            $.ajax({
                url : url,
                type : "post",
                data : {article_id:id,act:'copy'},
                dataType : "json",
                success:function(data){
                    if (data.status == 0) {
                        top.layer.msg(data.message);
                    } else {
                        top.layer.msg(data.message,{time:2000},function(){
                            window.location.href = location.href;
                        });
                    }
                }
            });
        } , function(){
            layer.close(); //再执行关闭
        })
    }

    // ajax_get_table('formSearch',"/index.php/Admin/Exam/ajaxExamList.html?p=1");

    // // ajax 抓取页面 form 为表单id  page 为当前第几页
    // function ajax_get_table(form,url){
    //     // cur_page = page; //当前页面 保存为全局变量
    //     // var info = $('#page_info').val();
    //     $.ajax({
    //         type : "POST",
    //         url:url,
    //         data : $('#'+form).serialize(),// 你的formid
    //         success: function(data){
    //             $("#ajaxList").html('');
    //             $("#ajaxList").append(data);
    //         }
    //     });
    //     return false;
    // }

    // $(".kind_id").change(function(){
    //     var kind_id = $(this).val();
    //     $("#kind_id").val(kind_id);
    // });
</script>

</body>

</html>